package com.cc.ndmall.promotion.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.cc.ndmall.promotion.entity.GrouponEntity;
import com.cc.ndmall.promotion.service.GrouponService;
import com.cc.ndmall.common.utils.PageUtils;
import com.cc.ndmall.common.utils.R;



/**
 * 
 *
 * @author oy
 * @email 1396004386@qq.com
 * @date 2020-11-07 09:22:55
 */
@RestController
@RequestMapping("promotion/groupon")
public class GrouponController {
    @Autowired
    private GrouponService grouponService;

    /**
     * 列表
     */
    @RequestMapping("/list")
   // @RequiresPermissions("promotion:groupon:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = grouponService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("promotion:groupon:info")
    public R info(@PathVariable("id") Integer id){
		GrouponEntity groupon = grouponService.getById(id);

        return R.ok().put("groupon", groupon);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("promotion:groupon:save")
    public R save(@RequestBody GrouponEntity groupon){
		grouponService.save(groupon);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("promotion:groupon:update")
    public R update(@RequestBody GrouponEntity groupon){
		grouponService.updateById(groupon);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("promotion:groupon:delete")
    public R delete(@RequestBody Integer[] ids){
		grouponService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
